package org.hxzon.workeasy.permissions.base;

import org.hxzon.workeasy.model.EasyUzer;
import org.hxzon.workeasy.util.WorkEasyUtil;

public class RolenamePermissionsChecker<T> implements PermissionsChecker<T> {
    private String[] _rolenames;

    public RolenamePermissionsChecker(String rolenameStr) {
        _rolenames = WorkEasyUtil.splitString(rolenameStr);
    }

    public boolean check(T targer, EasyUzer user) {
        for (String role : _rolenames) {
            if (user.hasRole(role)) {
                return true;
            }
        }
        return false;
    }
}
